<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
    <script src="/js/jquery-3.3.1.min.js"></script>
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="/js/bootstrap.min.js"></script>
    <script src="/js/md5.js"></script>
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .col-center-block {
            float: none;
            display: block;
            margin-left: auto;
            margin-right: auto;
        }
    </style>
</head>
<body>
<iframe MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no src="/html/head.html" height="100px" width="100%"></iframe>
<h3 align="center">抢购商城</h3>
<hr/>
<br/>
<div class="col-xs-6 col-md-8  col-center-block">
    <table id="list" class="table table-hover table-striped" style="text-align: center;">
        <thead>
        <tr>
            <td>商品图片</td>
            <td>商品ID</td>
            <td>商品名称</td>
            <td>商品原价</td>
            <td>商品秒杀价</td>
            <td>商品库存</td>
            <td>详情</td>
        </tr>
        </thead>
        <tbody>

        <!-- <tr>
            <td>asdad</td>
            <td>asdads</td>
            <td>asdad</td>
            <td>asdads</td>
            <td>asdad</td>
            <td>asdads</td>
            <td>asdad</td>
            <td>asdads</td>
        </tr> -->
        </tbody>
    </table>
</div>

</body>
<script>
    $(function () {
        // $("button").click(function () {
        //     var input = $("input").val();
        //     $("img").attr("src", "/seckill/verifyCode/" + input);
        //     input = hex_md5(input);
        //     console.info(input);
        //     console.info(hex_md5(input));
        //
        // });
        $.ajax({
            type: "GET",
            url: "/goods/list",
            success: function (result) {
                console.log(result);
                var data = result.data;
                console.log(data);
                for(i in data) {
                    goods_vo = data[i];
                    console.log(goods_vo);
                    var goods_id = goods_vo.goodsId;
                    var goods_name = goods_vo.goodsName;
                    var goods_old_price = goods_vo.goodsOldPrice;
                    var goods_price = goods_vo.goodsPrice;
                    var goods_stock = goods_vo.goodsStock;
                    var goods_thumb = goods_vo.goodsThumb;
                    var html = "<tr><td><img src='" + goods_thumb + "' alt='商品小图'/></td>"
                        + "<td>" + goods_id + "</td><td>"
                        + goods_name + "</td><td>" + goods_old_price + "</td><td>" + goods_price
                        + "</td><td>" + goods_stock + "</td>";
                    var url = "/html/goods_detail.html?goods_id=" + goods_id;
                    html += "<td><button type='button' class='btn btn-info' onclick='window.location.href=\"" + url + "\"'>查看详情";
                    html += "</button></td></tr>";
                    $("tbody").append(html);
                }
            }
        });
    });
</script>
</html>